//
//  FirstSpecialTableViewCell.m
//  Project_B
//
//  Created by 张闯的mac pro on 15/11/28.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "FirstSpecialTableViewCell.h"
#import "FirstModel.h"
#import "UIImageView+WebCache.h"

@interface FirstSpecialTableViewCell ()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *subLabel;
@property (nonatomic, strong) UIImageView *subImgView;

@end

@implementation FirstSpecialTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imgView];

        self.subImgView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.subImgView];
        [self.subImgView setImage:[UIImage imageNamed:@"zhuanti"]];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.titleLabel setFont:[UIFont systemFontOfSize:18]];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
        
        self.subLabel = [[UILabel alloc] init];
        self.subLabel.textAlignment = NSTextAlignmentCenter;
        [self.subLabel setFont:[UIFont systemFontOfSize:13]];
        self.subLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.subLabel];
        
    }
    
    return self;
}

- (void)setSpecialModel:(FirstModel *)specialModel
{
    if (_specialModel != specialModel) {
        _specialModel = specialModel;
    }
    
    self.titleLabel.text = specialModel.title;
    self.subLabel.text = specialModel.subhead;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:specialModel.image] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imgView.frame = CGRectMake(5, 5, 375 - 10, self.contentView.frame.size.height - 10);
    self.subImgView.frame = CGRectMake(320, 30, 30, 30);
    self.titleLabel.frame = CGRectMake(0, 0, 300, 30);
    self.titleLabel.center = self.contentView.center;
    self.subLabel.frame = CGRectMake(self.titleLabel.frame.origin.x + 50, self.titleLabel.frame.origin.y + 20, 200, 30);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
